


//
//  CrashManager.m
//  BaseDemo
//
//  Created by unispeed on 2019/7/11.
//  Copyright © 2019 coder. All rights reserved.
//

#import "CrashManager.h"
#import "AvoidCrash.h"

@implementation CrashManager

/**
 *    @brief    构建单例
 *
 *    @return    返回单例
 */
+ (id)shareInstance
{
    static dispatch_once_t once;
    Class class = [self class];
    static id instance;
    dispatch_once(&once, ^{
        instance = [[class alloc] init];
    });
    return instance;
}


- (void)setSelClassStrings:(NSArray <NSString *>*)stringArr;
{
    
    [AvoidCrash makeAllEffective];
    [AvoidCrash setupNoneSelClassStringsArr:stringArr];
    
    //监听通知:AvoidCrashNotification, 获取AvoidCrash捕获的崩溃日志的详细信息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dealwithCrashMessage:) name:AvoidCrashNotification object:nil];
    
}


- (void)dealwithCrashMessage:(NSNotification *)note {
    //注意:所有的信息都在userInfo中
    //你可以在这里收集相应的崩溃信息进行相应的处理(比如传到自己服务器)
    NSLog(@"crash信息%@",note.userInfo);
    
    //crash信息回调
    if (self.crashMessageBlock) {
        self.crashMessageBlock(note.userInfo);
    }
    
}



@end
